/**
 * Klasse zum Einlesen eines input.csv Files.
 * Die einzelnen Zeilen werden zu einem Datenobjekt umgewandelt
 * Autor: Thomas Kaiser
 * Datum: 19.12.2013
 */


package csvIn;


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

import dataObject.DataObject;


public class CSVReaderIn 
{	
	public ArrayList<String> sendung;
	
	public void Read()
	{
		 try
		 {
			FileInputStream fstream = new FileInputStream("input.csv");
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			String strLine;
			int count = 1;
			
			
			 while ((strLine = br.readLine()) != null)   
			  {
				 String[] buffer = strLine.split(";");
				 int total = 0;
				 int de = 0;
				 int en = 0;
				 
				 
				 if (buffer.length>10)
				 {
				 
				 try 
				 {			 	
				      de = Integer.parseInt(buffer[15]);
				 } 
				 catch (NumberFormatException e) {}
				 
				 try 
				 {			 	
				      en = Integer.parseInt(buffer[16]);
				 } 
				 catch (NumberFormatException e) {}
				 
				 
				 
				 total = de+en;

				 
				 if (total>1)
				 {
					 DataObject data = new DataObject(buffer, count);
					 data.printToXML();
					 count++;
					 Thread.sleep(5000);
				 }	}		 
			  }	
			 br.close();
			 in.close();
			 fstream.close();
			 
		 }
		 
		 catch(Exception e)
		 {
			 System.out.println(e.getMessage());
			 
			 
			 
		 }
	}
}
